package com.web.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.web.mall.entity.TbSpecification;
import com.web.mall.entity.TbSpecificationOption;
import com.web.mall.req.TbSpecificationReq;
import com.web.mall.service.ITbSpecificationOptionService;
import com.web.mall.utils.ResultBean;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/specOption")
public class TbSpecificationOptionController {
    @Autowired
    ITbSpecificationOptionService specificationOptionService;

    // 根据规格id查规格选项
    @GetMapping("/getBySpecId/{specId}")
    public ResultBean getBySpecId(@PathVariable("specId") Long specId) {
        LambdaQueryWrapper<TbSpecificationOption> wrapper = new LambdaQueryWrapper();
        wrapper.eq(!ObjectUtils.isEmpty(specId), TbSpecificationOption::getSpecId, specId);
        return ResultBean.ok(specificationOptionService.list(wrapper));
    }
}
